package com.eigaland.change_machine.customview

import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup
import android.widget.FrameLayout
import com.eigland.eigaland_lib.model.Label
import com.eigland.eigaland_lib.model.Seat
import com.eigland.eigaland_lib.model.Section
import movie6.posprintercept2.extensions.dip
import movie6.posprintercept2.extensions.removeParentView
import java.util.logging.Logger

public class SectionView(context: Context, attrs: AttributeSet?,section: Section) : FrameLayout(context, attrs) {
     var seats = ArrayList<Seat>()

     var labels = ArrayList<Label>()

     var labelViews = ArrayList<LabelView>()

     var seatViews = ArrayList<SeatView>()

     init {

          layoutParams = LayoutParams(dip(section.w), dip(section.h))

          seats.addAll(section.seats)

          labels.addAll(section.labels)


          seats.forEach {
               var seatView = SeatView(it,context,null)
               seatViews.add(seatView)
          }

          labels.forEach {

               var labelView = LabelView(context,it,null)
               labelViews.add(labelView)
          }

          // addData all seat views into section.

          seatViews.forEach {
               addView(it)
          }
          // make all label View
          // and addData all into section.
         labelViews.forEach {
              addView(it.removeParentView()) }
     }

}